package com.sasu.university_data.service.impl;
import com.sasu.university_data.entity.Area;
import com.sasu.university_data.service.AreaService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class AreaServiceImpl implements AreaService {
    @Resource
    private com.sasu.university_data.mapper.AreaMapper areaMapper;
    @Override
    public List<Area> queryAreaById( Integer id) {
        return areaMapper.queryAreaById(id);
    }

    @Override
    public long count (Integer aId) {
        return areaMapper.count(aId);
    }

    @Override
    public List<Area> selectByPage ( Integer aId, Integer page, Integer pageSize ) {
        if(page<=1) {
            page = 1;
        }
        if(pageSize<=0) {
            pageSize = 10;
        }
        return areaMapper.selectByPage(aId,(page - 1) * pageSize, pageSize);
    }

    @Override
    public boolean insert ( Area area ) {
        return areaMapper.insert(area)>0;
    }

    @Override
    public boolean update ( Area area ) {
        return areaMapper.update(area)>0;
    }

    @Override
    public boolean deleteById ( Integer aId ) {
        return areaMapper.deleteById(aId)>0;
    }

    @Override
    public boolean deleteByIds ( int[] aIds ) {
        return areaMapper.deleteByIds(aIds)>0;
    }
}
